#include "GladiatorOwnedStates.h"
#include "State.h"
#include "Gladiator.h"
#include "EntityNames.h"
#include "Inventory.h"
#include "Guardsman.h"
#include "Mercenary.h"
#include "Knight.h"
#include "DarkKnight.h"
#include "Utils.h"
#include "Cutscene.h"

#include <iostream>
#include <fstream>
#include <string>
#include <windows.h>
#include <cctype>		//isdigit
#include <stdio.h>		//atoi
#include <stdlib.h>

using namespace std;

//Methods for InitialState
//-----------------------------------------------------------------------------------------
InitialState* InitialState::Instance()
{
	static InitialState instance;
	return &instance;
}

void InitialState::Enter(Gladiator* glad)
{
	//enter InitialState
}

void InitialState::Execute(Gladiator* glad)
{
	cout << "Welcome to the Gladiator RPG\n" << endl;
	//display initial stats
	glad->displayStatus();
	//go to main menu
	glad->ChangeState(MainMenu::Instance());
}

void InitialState::Exit(Gladiator* glad)
{
	//exit InitialState
}


//Methods for MainMenu
//-----------------------------------------------------------------------------------------
MainMenu* MainMenu::Instance()
{
	static MainMenu instance;
	return &instance;
}

void MainMenu::Enter(Gladiator* glad)
{
	//enter MainMenu
	cout << "\n\nWelcome to the town of WestGate.  \nWhat would you like to do?" << endl;
	//make sure location is set to 'WestGate'
	glad->ChangeLocation(WestGate);
}

void MainMenu::Execute(Gladiator* glad)
{
	char selection = '0';
	while((selection != '8') && (glad->Location() != Dead))
	{
		cout << "1 - Go to the Arena" << endl;
		cout << "2 - Go to the Shop" << endl;
		cout << "3 - Go to the Tavern" << endl;
		cout << "4 - Go to the Inn" << endl;
		cout << "5 - Display Current Stats" << endl;
		cout << "6 - Display Inventory" << endl;
		cout << "7 - Load SaveData" << endl;
		cout << "8 - Quit" << endl;

		cout << "Enter choice: ";
		cin >> selection;

		switch(selection)
		{
		case '1':
			//Go to the Arena
			glad->ChangeState(theArena::Instance());
			cout << "\n\n" << endl;
			break;
		case '2':
			//Go to the Shop
			glad->ChangeState(theShop::Instance());
			break;
		case '3':
			//Go to the Tavern
			glad->ChangeState(theTavern::Instance());
			break;
		case '4':
			//Go to the Inn
			glad->ChangeState(theInn::Instance());
			break;
		case '5':
			//Display Current Stats
			cout << "\n\n" << endl;
			glad->displayStatus();
			cout << "\n\n" << endl;
			break;
		case '6':
			//Display Inventory
			cout << "\n\n" << endl;
			glad->pack.printInv();
			cout << "\n\n" << endl;
			break;
		case '7':
			//Load SaveData
			glad->ChangeState(LoadGame::Instance());
			break;
		case '8':
			//Quit
			glad->ChangeState(QuitGame::Instance());
			break;
		default:
			cout << "\n\nERROR: Invalid selection.\n" << endl;
			break;
		}

	}
	
}

void MainMenu::Exit(Gladiator* glad)
{
	//exit MainMenu
}


//Methods for Quit
//-----------------------------------------------------------------------------------------
QuitGame* QuitGame::Instance()
{
	static QuitGame instance;
	return &instance;
}

void QuitGame::Enter(Gladiator* glad)
{
	//enter Quit
	char isSure;
	//make sure user really wants to quit
	cout << "\n\nAre you sure you want to leave WestGate? (Y/N): ";
	cin >> isSure;
	isSure = toupper(isSure);
	if((isSure != 'Y') && (isSure != 'N'))
	{
		cout << "\nERROR: You have made an invalid selection\n" << endl;
		glad->ChangeState(MainMenu::Instance());
	}
	else if(isSure == 'N')
		glad->ChangeState(MainMenu::Instance());
}

void QuitGame::Execute(Gladiator* glad)
{
	//option to save data to text file
	char save;
	//make sure user really wants to quit
	cout << "Save game data before quitting? (Y/N): ";
	cin >> save;
	save = toupper(save);
	while((save != 'Y') && (save != 'N'))
	{
		cout << "\nERROR: You have made an invalid selection" << endl;
		cout << "\nSave game data before quitting? (Y/N): ";
		cin >> save;
		save = toupper(save);
	}
	if(save == 'Y')
	{
		cout << "\nSaving data..." << endl;
		glad->SaveData();
	}
	//must include option to load data

	cout << "\nThank you for playing" << endl;

	//change location to Quit
	glad->ChangeLocation(Quit);


}

void QuitGame::Exit(Gladiator* glad)
{
	//exit Quit
	return;
}


//Methods for LoadGame
//-----------------------------------------------------------------------------------------
LoadGame* LoadGame::Instance()
{
	static LoadGame instance;
	return &instance;
}

void LoadGame::Enter(Gladiator* glad)
{

	LoadGame::Execute(glad);
}

void LoadGame::Execute(Gladiator* glad)
{
	//enter LoadGame
	char isSure;
	//make sure user really wants to quit
	cout << "\n\nAre you sure you want to load save data?" << endl;
	cout << "All current game data will be lost.  Load? (Y/N): ";
	cin >> isSure;
	isSure = toupper(isSure);
	if((isSure != 'Y') && (isSure != 'N'))
	{
		cout << "\nERROR: You have made an invalid selection\n" << endl;
		//cheat code to give max stats
		if(isSure = '*')
		{
			glad->setData(20, 290, 65000, 145, 135, 135, 5000);
			glad->pack.setInv(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 10, 15, 15);
			glad->pack.setEquipArm(5);
			glad->pack.setEquipWeap(10);
		}
		glad->ChangeState(MainMenu::Instance());
	}
	else if(isSure == 'N')
		glad->ChangeState(MainMenu::Instance());
	else
	{
		cout << "\n\nSearching for savedata..." << endl;
		//LoadGame::Execute(glad);
		Sleep(1000);
		//load data from file
		if(!glad->loadSaveData())
			cout << "\nNo savedata found" << endl;
		else
		{
			cout << "\nSavedata successfully loaded" << endl;
		}
		Sleep(1000);
		//return to main menu
		glad->ChangeState(MainMenu::Instance());
	}
}

void LoadGame::Exit(Gladiator* glad)
{
	//exit LoadGame
}


//Methods for Inn
//-----------------------------------------------------------------------------------------
theInn* theInn::Instance()
{
	static theInn instance;
	return &instance;
}

void theInn::Enter(Gladiator* glad)
{
	//enter theInn
	cout << "\n\n" << GetNameOfEntity(ent_Inn) << ": Welcome to WestGate's one and only inn\n"
		<< setw(11) << left << " " <<  "We still have rooms available" << endl;
	glad->ChangeLocation(Inn);
	theInn::Execute(glad);
}

void theInn::Execute(Gladiator* glad)
{
	Sleep(800);
	char takeRoom;
	//make sure user really wants to quit
	cout << "\n" << GetNameOfEntity(ent_Inn) << ": Would you like to stay in a room?\n" << setw(11) << left << " " << "It's only 10g per night (Y/N): ";
	cin >> takeRoom;
	takeRoom = toupper(takeRoom);
	while((takeRoom != 'Y') && (takeRoom != 'N'))
	{
		Sleep(800);
		cout << "\n" << GetNameOfEntity(ent_Inn) << ": I'm sorry, I couldn't understand that" << endl;
		Sleep(800);
		cout << "\n" << GetNameOfEntity(ent_Inn) << ": Would you like to stay in a room?\n"
			<< setw(11) << left << " " <<  "It's only 10g per night (Y/N): ";
		cin >> takeRoom;
		takeRoom = toupper(takeRoom);
	}
	
	if(takeRoom == 'Y')
	{
		Sleep(800);
		//pay and make sure player has enough money
		if(glad->purchase(10))
		{
			
			cout << "\n" << GetNameOfEntity(ent_Inn) << ": Enjoy your stay" << endl;
			//print some Zzz's
			for(int i = 0; i < 5; i++)
			{
				cout << "\n" << GetNameOfEntity(ent_Glad) << ": Zzzz..." << endl;
				Sleep(800);
			}
			//call sleep function to restore hp
			glad->sleep();
			cout << "\n" << GetNameOfEntity(ent_Glad) << ": What a great sleep! I'm well rested and ready for more" << endl;
		}
		else
		{
			cout << "\n" << GetNameOfEntity(ent_Inn) << ": I'm sorry, but you don't have enough money" << endl;
		}
	}

	Sleep(800);
	cout << "\n" << GetNameOfEntity(ent_Inn) << ": Have a great day!\n" << setw(11) << left << " " << "Come again soon" << endl;
	glad->ChangeState(MainMenu::Instance());
}

void theInn::Exit(Gladiator* glad)
{
	//exit theInn
}


//Methods for Tavern
//-----------------------------------------------------------------------------------------
theTavern* theTavern::Instance()
{
	static theTavern instance;
	return &instance;
}

void theTavern::Enter(Gladiator* glad)
{
	//enter theTavern
	cout << "\n\n" << GetNameOfEntity(ent_Tav) << ": Welcome to WestGate's finest tavern\n"
		<< setw(11) << left << " " <<  "We've got food and booze galore" << endl;
	glad->ChangeLocation(Tavern);
	theTavern::Execute(glad);
}

void theTavern::Execute(Gladiator* glad)
{
	Sleep(800);
	char order = '0';
	int beerCount = 0;
	//make sure user really wants to quit
	cout << "\n" << GetNameOfEntity(ent_Tav) << ": What can I get for ya?\n" <<endl;
	while(order != '3')
	{
		char pay = '0';

		cout << "1 - I'll take a beer" << endl;
		cout << "2 - Get me a burger" << endl;
		cout << "3 - Not interested" << endl;
		cout << "Enter choice: ";
		cin >> order;

		Sleep(800);
		switch(order)
		{
		case '1':
			//grab a beer
			cout << "\n" << GetNameOfEntity(ent_Tav) << ": That'll be 3g" <<endl;
			cout << "\nPay? (Y/N)" << endl;
			cin >> pay;
			pay = toupper(pay);
			while((pay != 'Y') && (pay != 'N'))
			{
				cout << "\n" << GetNameOfEntity(ent_Tav) << ": Didn't quite understand that" <<endl;
				cout << "\nPay? (Y/N)" << endl;
				cin >> pay;
				pay = toupper(pay);
			}
			if(pay == 'Y')
			{
				Sleep(800);
				//pay and make sure player has enough money
				if(glad->purchase(3))
				{
					beerCount++;
					cout << "\n" << GetNameOfEntity(ent_Tav) << ": One cold beer comin' up!" << endl;
					//print some gulps's
					for(int i = 0; i < 3; i++)
					{
						cout << "\n" << GetNameOfEntity(ent_Glad) << ": *gulp gulp*" << endl;
						Sleep(800);
					}
					//call health boost to increment current hp by 10
					//glad->healthBoost(10);
					if(beerCount == 1)
						cout << "\n" << GetNameOfEntity(ent_Glad) << ": That was refreshing!" << endl;
					else if(beerCount == 2)
						cout << "\n" << GetNameOfEntity(ent_Glad) << ": Woo! Feeling good now!" << endl;
					else if(beerCount == 3)
					{
						//make sure players don't stack defense boosts
						if(!glad->gotDefBoost())
						{
							//add temp defense boost if player has drunk 5 beers at a time
							glad->hangover(10);
							cout << "\n" << GetNameOfEntity(ent_Glad) << ": Whoa, I'm feeling a little strange" << endl;
						}
					}
					else if (beerCount > 3)
						cout << "\n" << GetNameOfEntity(ent_Glad) << ": Ugh, I think I've had too much to drink" << endl;
				}
				else
				{
					cout << "\n" << GetNameOfEntity(ent_Tav) << ": You ain't got enough cash" << endl;
				}
			}
			Sleep(800);
			cout << "\n" << GetNameOfEntity(ent_Tav) << ": Anything else I can't get for ya?\n" << endl;
			break;
		case '2':
			//grab a burger
			cout << "\n" << GetNameOfEntity(ent_Tav) << ": That'll be 5g" <<endl;
			cout << "\nPay? (Y/N)" << endl;
			cin >> pay;
			pay = toupper(pay);
			while((pay != 'Y') && (pay != 'N'))
			{
				cout << "\n" << GetNameOfEntity(ent_Tav) << ": Didn't quite understand that" <<endl;
				cout << "\nPay? (Y/N)" << endl;
				cin >> pay;
				pay = toupper(pay);
			}
			if(pay == 'Y')
			{
				Sleep(800);
				//pay and make sure player has enough money
				if(glad->purchase(5))
				{
					
					cout << "\n" << GetNameOfEntity(ent_Tav) << ": One burger comin' up!" << endl;
					//print some munch's
					for(int i = 0; i < 4; i++)
					{
						cout << "\n" << GetNameOfEntity(ent_Glad) << ": *munch munch*" << endl;
						Sleep(800);
					}
					//call health boost to increment current hp by 10
					glad->healthBoost(10);
					cout << "\n" << GetNameOfEntity(ent_Glad) << ": Delicious! I feel better now!" << endl;
				}
				else
				{
					cout << "\n" << GetNameOfEntity(ent_Tav) << ": You ain't got enough cash" << endl;
				}
			}
			Sleep(800);
			cout << "\n" << GetNameOfEntity(ent_Tav) << ": Anything else I can't get for ya?\n" << endl;
			break;
		case '3':
			//no thanks
			cout << "\n" << GetNameOfEntity(ent_Glad) << ": No thanks, I'll pass" <<endl;
			Sleep(800);
			cout << "\n" << GetNameOfEntity(ent_Tav) << ": Alright, you know where to find me" <<endl;
			break;
		default:
			cout << "\n" << GetNameOfEntity(ent_Tav) << ": Didn't quite understand that\n" <<endl;
			break;

		}
	}
	glad->ChangeState(MainMenu::Instance());
}

void theTavern::Exit(Gladiator* glad)
{
	//exit theTavern
}


//Methods for Tavern
//-----------------------------------------------------------------------------------------
theShop* theShop::Instance()
{
	static theShop instance;
	return &instance;
}

void theShop::Enter(Gladiator* glad)
{
	//enter theShop
	cout << "\n\n" << GetNameOfEntity(ent_Shop) << ": Welcome to WestGate's item shop\n"
		<< setw(11) << left << " " <<  "You need anything, we got it" << endl;
	glad->ChangeLocation(Shop);
	theShop::Execute(glad);
}

void theShop::Execute(Gladiator* glad)
{
	Sleep(800);
	char option = '0';
	int itemNum = 0, equippedItem = 0, result = 1;
	char pay = '0', sure = '0';
	int n = 1;
	char pick = '0';
	bool found = false, equipped = false;

	while(option != '5')
	{
		char choice = 'x';
		string purchase, sell;

		cout << "\n" << GetNameOfEntity(ent_Shop) << ": What do ya need?\n" <<endl;
	
		
		cout << "1 - Buy" << endl;
		cout << "2 - Sell" << endl;
		cout << "3 - Equip Items" << endl;
		cout << "4 - Unequip Items" << endl;
		cout << "5 - Leave" << endl;
		cout << "Enter choice: ";
		cin >> option;

		Sleep(800);
		switch(option)
		{
		case '1':
			//buy items
			//make sure result is not equal to 0 before starting
			result = 1;
			while(result != 0)
			{
				bool valid = false;
				//display item menu
				cout << "\n" << endl;
				glad->pack.shopMenu();
				cout << "\n" << GetNameOfEntity(ent_Shop) << ": See anything ya like?\n"
					<< setw(11) << left << " " <<  "Enter item number, or '0' to quit: ";
				cin >> purchase;

				//make sure choice is a valid
				while(valid == false)
				{
					//convert string to int
					if (StringToInt(purchase, result))
					{
						if((result <= glad->pack.getSize()) && (result > 0))
						{
							valid = true;
							//convert to array location
							itemNum = result - 1;
							cout << "\n" << GetNameOfEntity(ent_Shop) << ": It's gonna cost ya " << glad->pack.getCost(itemNum) << "g" <<endl;
							cout << "\nPay? (Y/N)" << endl;
							cin >> pay;
							pay = toupper(pay);
							while((pay != 'Y') && (pay != 'N'))
							{
								cout << "\n" << GetNameOfEntity(ent_Shop) << ": Don't think I heard ya right" << endl;
								cout << "\nPay? (Y/N)" << endl;
								cin >> pay;
								pay = toupper(pay);
							}
							if(pay == 'Y')
							{
								Sleep(800);
								if(glad->purchase(glad->pack.getCost(itemNum)))
								{
									cout << "\n" << GetNameOfEntity(ent_Shop) << ": Here's your " << glad->pack.getName(itemNum) << endl;
									//increment inventory
									glad->pack.incrementInv(itemNum);
									Sleep(800);
									cout << "\n" << GetNameOfEntity(ent_Glad) << ": Thanks" << endl;
								}
								else
								{
									cout << "\n" << GetNameOfEntity(ent_Shop) << ": You need to earn yourself some more gold" << endl;
								}
							}
						}
						else if (result == 0)
						{
							//quit
							break;
						}
						else
						{
							cout << "\n" << GetNameOfEntity(ent_Shop) << ": Don't think I heard ya right\n" <<
								setw(11) << left << " "  << "Enter item number, or '0' to quit: ";
							cin >> purchase;
						}
					}
					else
					{
						cout << "\n" << GetNameOfEntity(ent_Shop) << ": Don't think I heard ya right\n" <<
							setw(11) << left << " "  << "Enter item number, or '0' to quit: ";
						cin >> purchase;
					}
				}
			}
			Sleep(800);
			if (purchase != "0")
			{
				cout << "\n" << GetNameOfEntity(ent_Shop) << ": See anything else ya need?\n" << endl;
			}
			break;
		case '2':
			//sell items
			result = 1; //reset result each time
			while(result != 0)
			{
				bool valid = false;
				int invCheck = 0;
				int count = 1, arrayLoc;
				cout << " \n" << endl;
				invCheck = glad->pack.sellMenu();

				cout << "\n" << GetNameOfEntity(ent_Shop) << ": What do you wanna sell?\n"
					<< setw(11) << left << " " <<  "Enter item number, or '0' to quit: ";
				cin >> sell;

					//make sure choice is valid
					while(valid == false)
					{
						//convert string to int
						if (StringToInt(sell, result))
						{
							Sleep(800);
							if((result <= invCheck) && (result > 0))
							{
								valid = true;

								//go back to convert user's selection to the actual array location
								for(int i = 0; i < glad->pack.getSize(); i++)
								{
									if(glad->pack.getInv(i) > 0)
									{
										if(result == count)
										{
											//save array location
											arrayLoc = i;
										}
										count++;
									}
								}
								if(result != 0)
								{
									cout << "\n" << GetNameOfEntity(ent_Shop) << ": Are you sure you want to sell " << glad->pack.getName(arrayLoc) <<endl;
									cout << "\nAre you sure? (Y/N)" << endl;
									cin >> sure;
									sure = toupper(sure);
									while((sure != 'Y') && (sure != 'N'))
									{
										cout << "\n" << GetNameOfEntity(ent_Shop) << ": Are you sure you want to sell " << glad->pack.getName(arrayLoc) <<endl;
										cout << "\nAre you sure? (Y/N)" << endl;
										cin >> sure;
										sure = toupper(sure);
									}
									if(sure == 'Y')
									{
										Sleep(800);
										//make sure item is not equipped
										if((glad->pack.getEquipWeap() != glad->pack.getEquipNum(arrayLoc)) && 
											(glad->pack.getEquipArm() != glad->pack.getEquipNum(arrayLoc)))
										{
											//decrement inventory
											if(glad->pack.decrementInv(arrayLoc))
											{
											cout << "\n" << GetNameOfEntity(ent_Shop) << ": Here's your " << glad->pack.getSell(arrayLoc) << "g" << endl;
											//add money to wallet
											glad->sell(glad->pack.getSell(arrayLoc));
											Sleep(800);
											cout << "\n" << GetNameOfEntity(ent_Glad) << ": Thanks" << endl;
											}
											else
											{
												cout << "\n" << GetNameOfEntity(ent_Shop) << ": You don't have any of those to sell" << endl;
											}
										}
										else
										{
											cout << "\n" << GetNameOfEntity(ent_Shop) << ": You can't sell equipped items" << endl;
										}
									}
								}
							}
							
							else if (result == 0)
							{
								//quit
								break;
							}
							else if(valid == false)
							{
								cout << "\n" << GetNameOfEntity(ent_Shop) << ": Don't think I heard ya right\n" <<
									setw(11) << left << " "  << "Enter item number, or '0' to quit: ";
								cin >> sell;
							}
						}
						else
						{
							cout << "\n" << GetNameOfEntity(ent_Shop) << ": Don't think I heard ya right\n" <<
								setw(11) << left << " "  << "Enter item number, or '0' to quit: ";
							cin >> sell;
						}
					}
				cout << endl;
			}
			break;
		case '3':
			//equip
			Sleep(800);
			cout << "\n" << GetNameOfEntity(ent_Shop) << ": What do you want to do?\n" << endl;
			while(choice != '3')
			{
				cout << "1 - Equip Weapon" << endl;
				cout << "2 - Equip Armor" << endl;
				cout << "3 - Quit" << endl;
				cout << "Enter choice: ";
				cin >> choice;
				
				Sleep(800);
				if(choice == '1')
				{
					//if no weapons are already equipped
					if(glad->pack.getEquipWeap() == 0)
					{
						n = 1;
						//equip weapon
						cout << "\n" << GetNameOfEntity(ent_Shop) << ": Which weapon do you want to equip?\n" << endl;
						for(int i = 0; i < glad->pack.getSize(); i++)
						{
							if((glad->pack.getInv(i) > 0) && (glad->pack.getType(i) == 'w'))
							{
								cout << n << " - " << glad->pack.getName(i) << endl;
								n++;
								found = true;
							}
						}
						Sleep(800);
						if(found == false)
						{
							//no weapons in inventory
							cout << "\n" << GetNameOfEntity(ent_Shop) << ": Sorry, but it looks like you don't have any weapons\n" << endl;
						}
						else
						{
							cout << "\nEnter number to equip item, or 0 to quit: ";
							cin >> pick;

							if(isdigit(pick) && (pick != '0'))
							{
								//convert to int
								pick = atoi(&pick);
								//reset n
								n = 1;
		
								Sleep(800);
								for(int i = 0; i < glad->pack.getSize(); i++)
								{
									if((glad->pack.getInv(i) > 0) && (glad->pack.getType(i) == 'w'))
									{
										if(pick == n)
										{
											//make sure player is at required level
											if(glad->getLevel() < glad->pack.getReqLevel(i))
											{
												cout << "\n" << GetNameOfEntity(ent_Shop) << ": You need to get a bit stronger before you can use this one\n" << endl;
												//set to a false true, so player won't recieve error message
												equipped = true;
											}
											else
											{
												//equip
												glad->pack.setEquipWeap(glad->pack.getEquipNum(i));
												//add attack boost
												glad->weaponBoost(glad->pack.getItemBoost(i));

												cout << "\n" << GetNameOfEntity(ent_Shop) << ": " << glad->pack.getName(i) <<" is now equipped\n" << endl;
												equipped = true;
												//force to quit after weapon is equipped
												//choice = '3';
												break;
											}
										}
										n++;
									}
								}
								if(equipped == false)
								{
									cout << "\n" << GetNameOfEntity(ent_Shop) << ": Don't think I heard ya right\n" << endl;
								}
							}
							else if (pick != '0')
							{
								cout << "\n" << GetNameOfEntity(ent_Shop) << ": Don't think I heard ya right\n" << endl;
							}
							if(pick == '0')
							{
								//force it to quit
								choice = '3';
							}
						}
					}
					else
					{
						cout << "\n" << GetNameOfEntity(ent_Shop) << ": You need to unequip your weapon first\n" << endl;
					}
				}
				if(choice == '2')
				{
					//if no armor is equipped
					if(glad->pack.getEquipArm() == 0)
					{
						n = 1;
						//equip armor
						cout << "\n" << GetNameOfEntity(ent_Shop) << ": Which armor do you want to equip?\n" << endl;
						for(int i = 0; i < glad->pack.getSize(); i++)
						{
							if((glad->pack.getInv(i) > 0) && (glad->pack.getType(i) == 'a'))
							{
								cout << n << " - " << glad->pack.getName(i) << endl;
								n++;
								found = true;
							}
						}
						Sleep(800);
						if(found == false)
						{
							//no armor in inventory
							cout << "\n" << GetNameOfEntity(ent_Shop) << ": Sorry, but it looks like you don't have any armor\n" << endl;
						}
						else
						{
							cout << "\nEnter number to equip item, or 0 to quit: ";
							cin >> pick;

							if(isdigit(pick) && (pick != '0'))
							{
								//convert to int
								pick = atoi(&pick);
								//reset n
								n = 1;
		
								Sleep(800);
								for(int i = 0; i < glad->pack.getSize(); i++)
								{
									if((glad->pack.getInv(i) > 0) && (glad->pack.getType(i) == 'a'))
									{
										if(pick == n)
										{
											//make sure player is at required level
											if(glad->getLevel() < glad->pack.getReqLevel(i))
											{
												cout << "\n" << GetNameOfEntity(ent_Shop) << ": You need to get a bit stronger before you can use this one\n" << endl;
												//set to a false true, so player won't recieve error message
												equipped = true;
											}
											else
											{
												//equip
												glad->pack.setEquipArm(glad->pack.getEquipNum(i));
												//add attack boost
												glad->armorBoost(glad->pack.getItemBoost(i));

												cout << "\n" << GetNameOfEntity(ent_Shop) << ": " << glad->pack.getName(i) <<" is now equipped\n" << endl;
												equipped = true;
												//force to quit after armor is equipped
												//choice = '3';
												break;
											}
										}
										n++;
									}
								}
								if(equipped == false)
								{
									cout << "\n" << GetNameOfEntity(ent_Shop) << ": Don't think I heard ya right\n" << endl;
								}
							}
							else if (pick != '0')
							{
								cout << "\n" << GetNameOfEntity(ent_Shop) << ": Don't think I heard ya right\n" << endl;
							}
							if(pick == '0')
							{
								//force it to quit
								choice = '3';
							}
						}
					}
					else
					{
						cout << "\n" << GetNameOfEntity(ent_Shop) << ": You need to unequip your armor first\n" << endl;
					}
				}
				if((choice != '1') && (choice != '2') && (choice != '3'))
					cout << "\n" << GetNameOfEntity(ent_Shop) << ": Don't think I heard ya right\n" << endl;
			}
			break;
		case '4':
			//unequip
			Sleep(800);
			cout << "\n" << GetNameOfEntity(ent_Shop) << ": What do you want to do?\n" << endl;
			while(choice != '3')
			{
				cout << "1 - Unequip Weapon" << endl;
				cout << "2 - Unequip Armor" << endl;
				cout << "3 - Quit" << endl;
				cout << "Enter choice: ";
				cin >> choice;
				
				Sleep(800);
				if(choice == '1')
				{
					//if weapon is already equipped
					if(glad->pack.getEquipWeap() != 0)
					{
						for(int i = 0; i < glad->pack.getSize(); i++)
						{
							if(glad->pack.getEquipWeap() == glad->pack.getEquipNum(i))
								equippedItem = i;

						}
						cout << "\n" << GetNameOfEntity(ent_Shop) << ": Are you sure you want to remove " << 
							glad->pack.getName(equippedItem) << "?" <<endl;
						cout << "\nAre you sure? (Y/N)" << endl;
						cin >> sure;
						sure = toupper(sure);
						while((sure != 'Y') && (sure != 'N'))
						{
							cout << "\n" << GetNameOfEntity(ent_Shop) << ": Are you sure you want to remove " << 
								glad->pack.getName(equippedItem) << "?" <<endl;
							cout << "\nAre you sure? (Y/N)" << endl;
							cin >> sure;
							sure = toupper(sure);
						}
						Sleep(800);
						if(sure == 'Y')
						{
							//remove weapon
							glad->pack.setEquipWeap(0);
							//remove boost
							glad->removeWeapon(glad->pack.getItemBoost(equippedItem));
							cout << "\n" << GetNameOfEntity(ent_Shop) << ": " << glad->pack.getName(equippedItem) << " has been removed\n" << endl;
						}
						if(sure == 'N')
						{
							cout << "\n" << GetNameOfEntity(ent_Shop) << ": What do you want to do?\n" << endl;
						}
					}
					else
					{
						cout << "\n" << GetNameOfEntity(ent_Shop) << ": You don't have any weapons equipped right now\n" << endl;
					}
				}
				if(choice == '2')
				{
					//if armor is already equipped
					if(glad->pack.getEquipArm() != 0)
					{
						for(int i = 0; i < glad->pack.getSize(); i++)
						{
							if(glad->pack.getEquipArm() == glad->pack.getEquipNum(i))
								equippedItem = i;

						}
						cout << "\n" << GetNameOfEntity(ent_Shop) << ": Are you sure you want to remove " << 
							glad->pack.getName(equippedItem) << "?" <<endl;
						cout << "\nAre you sure? (Y/N)" << endl;
						cin >> sure;
						sure = toupper(sure);
						while((sure != 'Y') && (sure != 'N'))
						{
							cout << "\n" << GetNameOfEntity(ent_Shop) << ": Are you sure you want to remove " << 
								glad->pack.getName(equippedItem) << "?" <<endl;
							cout << "\nAre you sure? (Y/N)" << endl;
							cin >> sure;
							sure = toupper(sure);
						}
						Sleep(800);
						if(sure == 'Y')
						{
							//remove weapon
							glad->pack.setEquipArm(0);
							//remove boost
							glad->removeArmor(glad->pack.getItemBoost(equippedItem));
							cout << "\n" << GetNameOfEntity(ent_Shop) << ": " << glad->pack.getName(equippedItem) << " has been removed\n" << endl;
						}
						if(sure == 'N')
						{
							cout << "\n" << GetNameOfEntity(ent_Shop) << ": What do you want to do?\n" << endl;
						}
					}
					else
					{
						cout << "\n" << GetNameOfEntity(ent_Shop) << ": You don't have any armor equipped right now\n" << endl;
					}
				}
				if((choice != '1') && (choice != '2') && (choice != '3'))
					cout << "\n" << GetNameOfEntity(ent_Shop) << ": Don't think I heard ya right\n" << endl;
			}
			break;
		case '5':
			//leave
			cout << "\n" << GetNameOfEntity(ent_Glad) << ": I don't think I need anything right now" <<endl;
			Sleep(800);
			cout << "\n" << GetNameOfEntity(ent_Shop) << ": Suit yourself" <<endl;
			break;
		default:
			cout << "\n" << GetNameOfEntity(ent_Shop) << ": Don't think I heard ya right\n" <<endl;
			break;

		}
	}
	glad->ChangeState(MainMenu::Instance());
}

void theShop::Exit(Gladiator* glad)
{
	//exit theShop
}


//Methods for theArena
//-----------------------------------------------------------------------------------------
theArena* theArena::Instance()
{
	static theArena instance;
	return &instance;
}

void theArena::Enter(Gladiator* glad)
{
	//enter theArena
	cout << "\n\n" << GetNameOfEntity(ent_Area) << ": Welcome to the Arena\n"
		<< setw(11) << left << " " <<  "Start yourself off with an easy\n" << setw(13) <<
		left << " " << "match, then work your way up\n" << endl;
	Sleep(800);
	glad->ChangeLocation(Shop);
	glad->ChangeLocation(Arena);
	theArena::Execute(glad);
}

void theArena::Execute(Gladiator* glad)
{
	//execute theArena
	Guardsman guard;
	Mercenary merc;
	Knight knig;
	DarkKnight boss;
	int xp, mon;
	int battleCount = 1;
	bool gladDead = false;
	bool enemDead = false;
	char choice = '0';
	char selection = '0';
	while(selection != '6')
	{
		cout << "1 - Match 1" << endl;
		cout << "2 - Match 2" << endl;
		cout << "3 - Match 3" << endl;
		cout << "4 - Match 4" << endl;
		cout << "5 - Match 5" << endl;
		cout << "6 - Leave" << endl;

		cout << "Enter choice: ";
		cin >> selection;

		//make sure these values are reset properly
		gladDead = false;
		enemDead = false;

		switch(selection)
		{
		case '1':
			//match 1 - one guardsman
			guard.setData(75, 60, 50);
			cout << "\n\n" << setw(5) << left << " " << "A guard has appeared..." << endl;
			while((gladDead != true) && (enemDead != true))
			{
				cout << "\nHP: ";
				glad->printHP();
				cout << endl;
				cout << "1 - Attack" << endl;
				cout << "2 - Defend" << endl;
				cout << "3 - Use Item" << endl;
				cout << "4 - Run away" << endl;
				cout << "Enter choice: ";
				cin >> choice;

				Sleep(800);
				if(choice == '1')
				{
					//attack
					cout << "\n" << setw(5) << left << " " << GetNameOfEntity(ent_Glad) << " is attacking..." << endl;
					Sleep(800);
					enemDead = guard.Damage(glad->AttackDamage());
					//make sure enemy is not dead first
					if(enemDead == false)
					{
						Sleep(800);
						gladDead = glad->ReceiveDamage(guard.Attack());
					}
				}
				else if (choice == '2')
				{
					//defend
					cout << "\n" << setw(5) << left << " " << GetNameOfEntity(ent_Glad) << " is defending..." << endl;
					Sleep(800);
					gladDead = glad->OnDefend(guard.Attack());
				}
				else if (choice == '3')
				{
					//use item
					bool found = false;
					char pick = '0';
					int n = 1;
					//display all usable items
					cout << setw(26) << left << "\nITEMS" << "QTY" << endl;
					cout << "------------------------------" << endl;
					for(int i = 0; i < glad->pack.getSize(); i++)
					{
						if((glad->pack.getInv(i) > 0) && (glad->pack.getType(i) == 'h'))
						{
							cout << n << " - " << setw(21) << left << glad->pack.getName(i) << setw(3) << right << glad->pack.getInv(i) << endl;
							n++;
							found = true;
						}
					}
					if(found == false)
					{
						//no items in inventory
						cout << "\nNo useable items in inventory\n" << endl;
					}
					else
					{
						cout << "\nEnter number to use item, or 0 to return to options: ";
						cin >> pick;

						if(isdigit(pick) && (pick != '0'))
						{
							//convert to int
							pick = atoi(&pick);
							//reset n
							n = 1;

							for(int i = 0; i < glad->pack.getSize(); i++)
							{
								if((glad->pack.getInv(i) > 0) && (glad->pack.getType(i) == 'h'))
								{
									if(pick == n)
									{
										//add health boost
										glad->healthBoost(glad->pack.getItemBoost(i));
										//decrement item from inventory
										glad->pack.decrementInv(i);
										
										cout << "\n" << setw(5) << left << " " << GetNameOfEntity(ent_Glad) << " is using item..." << endl;
										cout << "\n" << setw(12) << left << " " << "+" << glad->pack.getItemBoost(i) << "HP" << endl;

										//enemy still gets to attack
										gladDead = glad->ReceiveDamage(guard.Attack());
									}
									n++;
								}
							}
						}
						else if (pick != '0')
						{
							cout << "Not an option" << endl;
						}
					}

				}
				else if (choice == '4')
				{
					//run away  (still take damage)
					cout << "\n" << setw(5) << left << " " << GetNameOfEntity(ent_Glad) << " is running away..." << endl;
					Sleep(800);
					gladDead = glad->ReceiveDamage(guard.Attack());
					return;
				}
				//check if player has a defense bonus and decrement each round
				glad->defenseCheck();
			}
			if(enemDead == true)
			{
				cout << "\n" << GetNameOfEntity(ent_Glad) << ": Alright!" << endl;
				cout << setw(8) << left << "\nVICTORY!\n" << endl;
				//EXP and money rewareded are dependant upon level
				if(glad->getLevel() < 5)
				{
					xp = 50;
					mon = 25;
				}
				else
				{
					xp = 25;
					mon = 15;
				}
				glad->victory(xp, mon);
			}
			if(gladDead == true)
			{
				cout << "\n\n\n" << setw(8) << left << " " << "GAME OVER\n\n" << endl;
				glad->ChangeLocation(Dead);
				return;
			}
			cout << "\n" << endl;
			break;
		case '2':
			//match 2 - three guardsmen
			guard.setData(150, 80, 75);
			cout << "\n\n" << setw(5) << left << " " << "A guard has appeared..." << endl;
			for(int m = 0; m < 3; m++)
			{

				while((gladDead != true) && (enemDead != true))
				{
					cout << "\nHP: ";
					glad->printHP();
					cout << endl;
					cout << "1 - Attack" << endl;
					cout << "2 - Defend" << endl;
					cout << "3 - Use Item" << endl;
					cout << "4 - Run away" << endl;
					cout << "Enter choice: ";
					cin >> choice;

					Sleep(800);
					if(choice == '1')
					{
						//attack
						cout << "\n" << setw(5) << left << " " << GetNameOfEntity(ent_Glad) << " is attacking..." << endl;
						Sleep(800);
						enemDead = guard.Damage(glad->AttackDamage());
						//make sure enemy is not dead first
						if(enemDead == false)
						{
							Sleep(800);
							gladDead = glad->ReceiveDamage(guard.Attack());
						}
					}
					else if (choice == '2')
					{
						//defend
						cout << "\n" << setw(5) << left << " " << GetNameOfEntity(ent_Glad) << " is defending..." << endl;
						Sleep(800);
						gladDead = glad->OnDefend(guard.Attack());
					}
					else if (choice == '3')
					{
						//use item
						bool found = false;
						char pick = '0';
						int n = 1;
						//display all usable items
						cout << setw(26) << left << "\nITEMS" << "QTY" << endl;
						cout << "------------------------------" << endl;
						for(int i = 0; i < glad->pack.getSize(); i++)
						{
							if((glad->pack.getInv(i) > 0) && (glad->pack.getType(i) == 'h'))
							{
								cout << n << " - " << setw(21) << left << glad->pack.getName(i) << setw(3) << right << glad->pack.getInv(i) << endl;
								n++;
								found = true;
							}
						}
						if(found == false)
						{
							//no items in inventory
							cout << "\nNo useable items in inventory\n" << endl;
						}
						else
						{
							cout << "\nEnter number to use item, or 0 to return to options: ";
							cin >> pick;

							if(isdigit(pick) && (pick != '0'))
							{
								//convert to int
								pick = atoi(&pick);
								//reset n
								n = 1;

								for(int i = 0; i < glad->pack.getSize(); i++)
								{
									if((glad->pack.getInv(i) > 0) && (glad->pack.getType(i) == 'h'))
									{
										if(pick == n)
										{
											//add health boost
											glad->healthBoost(glad->pack.getItemBoost(i));
											//decrement item from inventory
											glad->pack.decrementInv(i);
											
											cout << "\n" << setw(5) << left << " " << GetNameOfEntity(ent_Glad) << " is using item..." << endl;
											cout << "\n" << setw(12) << left << " " << "+" << glad->pack.getItemBoost(i) << "HP" << endl;

											//enemy still gets to attack
											gladDead = glad->ReceiveDamage(guard.Attack());
										}
										n++;
									}
								}
							}
							else if (pick != '0')
							{
								cout << "Not an option" << endl;
							}
						}

					}
					else if (choice == '4')
					{
						//run away  (still take damage)
						cout << "\n" << setw(5) << left << " " << GetNameOfEntity(ent_Glad) << " is running away..." << endl;
						Sleep(800);
						gladDead = glad->ReceiveDamage(guard.Attack());
						return;
					}
					//check if player has a defense bonus and decrement each round
					glad->defenseCheck();
				}
				if(gladDead == true)
					break;
				if(m < 2)
				{
					//since the same guard object is being used, 
					//we need to reset some values
					enemDead = false;
					guard.setData(150, 80, 75);
					cout << "\n\n" << setw(5) << left << " " << "Another guard has appeared..." << endl;
				}
			}
			if(enemDead == true)
			{
				cout << "\n" << GetNameOfEntity(ent_Glad) << ": Is that all ya got?" << endl;
				cout << setw(8) << left << "\nVICTORY!\n" << endl;
				//EXP and money rewareded are dependant upon level
				if(glad->getLevel() < 9)
				{
					xp = 100;
					mon = 50;
				}
				else
				{
					xp = 50;
					mon = 20;
				}
				glad->victory(xp, mon);
			}
			if(gladDead == true)
			{
				cout << "\n\n\n" << setw(8) << left << " " << "GAME OVER\n\n" << endl;
				glad->ChangeLocation(Dead);
				return;
			}
			cout << "\n" << endl;
			break;
		case '3':
			//match 3 - two mercenaries
			merc.setData(300, 125, 120);
			cout << "\n\n" << setw(5) << left << " " << "A mercenary has appeared..." << endl;
			for(int m = 0; m < 2; m++)
			{

				while((gladDead != true) && (enemDead != true))
				{
					cout << "\nHP: ";
					glad->printHP();
					cout << endl;
					cout << "1 - Attack" << endl;
					cout << "2 - Defend" << endl;
					cout << "3 - Use Item" << endl;
					cout << "4 - Run away" << endl;
					cout << "Enter choice: ";
					cin >> choice;

					Sleep(800);
					if(choice == '1')
					{
						//attack
						cout << "\n" << setw(5) << left << " " << GetNameOfEntity(ent_Glad) << " is attacking..." << endl;
						Sleep(800);
						enemDead = merc.Damage(glad->AttackDamage());
						//make sure enemy is not dead first
						if(enemDead == false)
						{
							Sleep(800);
							gladDead = glad->ReceiveDamage(merc.Attack());
						}
					}
					else if (choice == '2')
					{
						//defend
						cout << "\n" << setw(5) << left << " " << GetNameOfEntity(ent_Glad) << " is defending..." << endl;
						Sleep(800);
						gladDead = glad->OnDefend(merc.Attack());
					}
					else if (choice == '3')
					{
						//use item
						bool found = false;
						char pick = '0';
						int n = 1;
						//display all usable items
						cout << setw(26) << left << "\nITEMS" << "QTY" << endl;
						cout << "------------------------------" << endl;
						for(int i = 0; i < glad->pack.getSize(); i++)
						{
							if((glad->pack.getInv(i) > 0) && (glad->pack.getType(i) == 'h'))
							{
								cout << n << " - " << setw(21) << left << glad->pack.getName(i) << setw(3) << right << glad->pack.getInv(i) << endl;
								n++;
								found = true;
							}
						}
						if(found == false)
						{
							//no items in inventory
							cout << "\nNo useable items in inventory\n" << endl;
						}
						else
						{
							cout << "\nEnter number to use item, or 0 to return to options: ";
							cin >> pick;

							if(isdigit(pick) && (pick != '0'))
							{
								//convert to int
								pick = atoi(&pick);
								//reset n
								n = 1;

								for(int i = 0; i < glad->pack.getSize(); i++)
								{
									if((glad->pack.getInv(i) > 0) && (glad->pack.getType(i) == 'h'))
									{
										if(pick == n)
										{
											//add health boost
											glad->healthBoost(glad->pack.getItemBoost(i));
											//decrement item from inventory
											glad->pack.decrementInv(i);
											
											cout << "\n" << setw(5) << left << " " << GetNameOfEntity(ent_Glad) << " is using item..." << endl;
											cout << "\n" << setw(12) << left << " " << "+" << glad->pack.getItemBoost(i) << "HP" << endl;

											//enemy still gets to attack
											gladDead = glad->ReceiveDamage(merc.Attack());
										}
										n++;
									}
								}
							}
							else if (pick != '0')
							{
								cout << "Not an option" << endl;
							}
						}

					}
					else if (choice == '4')
					{
						//run away  (still take damage)
						cout << "\n" << setw(5) << left << " " << GetNameOfEntity(ent_Glad) << " is running away..." << endl;
						Sleep(800);
						gladDead = glad->ReceiveDamage(merc.Attack());
						return;
					}
					//check if player has a defense bonus and decrement each round
					glad->defenseCheck();
				}
				if(gladDead == true)
					break;
				if(m < 1)
				{
					//since the same guard object is being used, 
					//we need to reset some values
					enemDead = false;
					merc.setData(300, 125, 120);
					cout << "\n\n" << setw(5) << left << " " << "Another mercenary has appeared..." << endl;
				}
			}
			if(enemDead == true)
			{
				cout << "\n" << GetNameOfEntity(ent_Glad) << ": I'm undefeatable!" << endl;
				cout << setw(8) << left << "\nVICTORY!\n" << endl;
				//EXP and money rewareded are dependant upon level
				if(glad->getLevel() < 13)
				{
					xp = 400;
					mon = 200;
				}
				else
				{
					xp = 150;
					mon = 75;
				}
				glad->victory(xp, mon);
			}
			if(gladDead == true)
			{
				cout << "\n\n\n" << setw(8) << left << " " << "GAME OVER\n\n" << endl;
				glad->ChangeLocation(Dead);
				return;
			}
			cout << "\n" << endl;
			break;
		case '4':
			//match 4 - three guards, two mercenaries
			guard.setData(300, 185, 170);
			merc.setData(350, 200, 170);
			

			cout << "\n\n" << setw(5) << left << " " << "A guard has appeared..." << endl;
			for(int m = 0; m < 5; m++)
			{

				while((gladDead != true) && (enemDead != true))
				{
					cout << "\nHP: ";
					glad->printHP();
					cout << endl;
					cout << "1 - Attack" << endl;
					cout << "2 - Defend" << endl;
					cout << "3 - Use Item" << endl;
					cout << "4 - Run away" << endl;
					cout << "Enter choice: ";
					cin >> choice;

					Sleep(800);
					if(choice == '1')
					{
						//attack
						cout << "\n" << setw(5) << left << " " << GetNameOfEntity(ent_Glad) << " is attacking..." << endl;
						Sleep(800);
						if((battleCount%2) == 0)
							enemDead = merc.Damage(glad->AttackDamage());
						else
							enemDead = guard.Damage(glad->AttackDamage());
						//make sure enemy is not dead first
						if(enemDead == false)
						{
							Sleep(800);
							if((battleCount%2) == 0)
								gladDead = glad->ReceiveDamage(merc.Attack());
							else
								gladDead = glad->ReceiveDamage(guard.Attack());
						}
					}
					else if (choice == '2')
					{
						//defend
						cout << "\n" << setw(5) << left << " " << GetNameOfEntity(ent_Glad) << " is defending..." << endl;
						Sleep(800);
						if((battleCount%2) == 0)
							gladDead = glad->OnDefend(merc.Attack());
						else
							gladDead = glad->OnDefend(guard.Attack());
					}
					else if (choice == '3')
					{
						//use item
						bool found = false;
						char pick = '0';
						int n = 1;
						//display all usable items
						cout << setw(26) << left << "\nITEMS" << "QTY" << endl;
						cout << "------------------------------" << endl;
						for(int i = 0; i < glad->pack.getSize(); i++)
						{
							if((glad->pack.getInv(i) > 0) && (glad->pack.getType(i) == 'h'))
							{
								cout << n << " - " << setw(21) << left << glad->pack.getName(i) << setw(3) << right << glad->pack.getInv(i) << endl;
								n++;
								found = true;
							}
						}
						if(found == false)
						{
							//no items in inventory
							cout << "\nNo useable items in inventory\n" << endl;
						}
						else
						{
							cout << "\nEnter number to use item, or 0 to return to options: ";
							cin >> pick;

							if(isdigit(pick) && (pick != '0'))
							{
								//convert to int
								pick = atoi(&pick);
								//reset n
								n = 1;

								for(int i = 0; i < glad->pack.getSize(); i++)
								{
									if((glad->pack.getInv(i) > 0) && (glad->pack.getType(i) == 'h'))
									{
										if(pick == n)
										{
											//add health boost
											glad->healthBoost(glad->pack.getItemBoost(i));
											//decrement item from inventory
											glad->pack.decrementInv(i);
											
											cout << "\n" << setw(5) << left << " " << GetNameOfEntity(ent_Glad) << " is using item..." << endl;
											cout << "\n" << setw(12) << left << " " << "+" << glad->pack.getItemBoost(i) << "HP" << endl;

											//enemy still gets to attack
											if((battleCount%2) == 0)
												gladDead = glad->ReceiveDamage(merc.Attack());
											else
												gladDead = glad->ReceiveDamage(guard.Attack());
										}
										n++;
									}
								}
							}
							else if (pick != '0')
							{
								cout << "Not an option" << endl;
							}
						}

					}
					else if (choice == '4')
					{
						//run away  (still take damage)
						cout << "\n" << setw(5) << left << " " << GetNameOfEntity(ent_Glad) << " is running away..." << endl;
						Sleep(800);
						if((battleCount%2) == 0)
							gladDead = glad->ReceiveDamage(merc.Attack());
						else
							gladDead = glad->ReceiveDamage(guard.Attack());
						return;
					}
					//check if player has a defense bonus and decrement each round
					glad->defenseCheck();
				}
				if(gladDead == true)
					break;
				if(m < 4)
				{
					//since the same guard object is being used, 
					//we need to reset some values
					enemDead = false;
					guard.setData(300, 185, 170);
					merc.setData(350, 200, 170);
					if((battleCount) == 1)
						cout << "\n\n" << setw(5) << left << " " << "A mercenary has appeared..." << endl;
					else if((battleCount) == 2)
						cout << "\n\n" << setw(5) << left << " " << "Another guard has appeared..." << endl;
					else if((battleCount) == 3)
						cout << "\n\n" << setw(5) << left << " " << "Another mercenary has appeared..." << endl;
					else if((battleCount) == 4)
						cout << "\n\n" << setw(5) << left << " " << "Another guard has appeared..." << endl;

					battleCount++;
				}
			}
			if(enemDead == true)
			{
				cout << "\n" << GetNameOfEntity(ent_Glad) << ": Another loss for the bad guys" << endl;
				cout << setw(8) << left << "\nVICTORY!\n" << endl;
				//EXP and money rewareded are dependant upon level
				if(glad->getLevel() < 18)
				{
					xp = 1000;
					mon = 300;
				}
				else
				{
					xp = 500;
					mon = 150;
				}
				glad->victory(xp, mon);
			}
			if(gladDead == true)
			{
				cout << "\n\n\n" << setw(8) << left << " " << "GAME OVER\n\n" << endl;
				glad->ChangeLocation(Dead);
				return;
			}
			cout << "\n" << endl;
			break;
		case '5':
			//match 5 - three guards, two mercenaries, three knights and ???
			guard.setData(350, 210, 195);
			merc.setData(400, 230, 195);
			knig.setData(450, 230, 205);

			cout << "\n\n" << setw(5) << left << " " << "A knight has appeared..." << endl;
			for(int m = 0; m < 7; m++)
			{

				while((gladDead != true) && (enemDead != true))
				{
					cout << "\nHP: ";
					glad->printHP();
					cout << endl;
					cout << "1 - Attack" << endl;
					cout << "2 - Defend" << endl;
					cout << "3 - Use Item" << endl;
					cout << "4 - Run away" << endl;
					cout << "Enter choice: ";
					cin >> choice;

					Sleep(800);
					if(choice == '1')
					{
						//attack
						cout << "\n" << setw(5) << left << " " << GetNameOfEntity(ent_Glad) << " is attacking..." << endl;
						Sleep(800);
						if((battleCount == 1) || (battleCount == 6) || (battleCount == 7))
							enemDead = knig.Damage(glad->AttackDamage());
						else if ((battleCount == 2) || (battleCount == 3))
							enemDead = guard.Damage(glad->AttackDamage());
						else if ((battleCount == 4) || (battleCount == 5))
							enemDead = merc.Damage(glad->AttackDamage());
						//make sure enemy is not dead first
						if(enemDead == false)
						{
							Sleep(800);
							if((battleCount == 1) || (battleCount == 6) || (battleCount == 7))
								gladDead = glad->ReceiveDamage(knig.Attack());
							else if ((battleCount == 2) || (battleCount == 3))
								gladDead = glad->ReceiveDamage(guard.Attack());
							else if ((battleCount == 4) || (battleCount == 5))
								gladDead = glad->ReceiveDamage(merc.Attack());
						}
					}
					else if (choice == '2')
					{
						//defend
						cout << "\n" << setw(5) << left << " " << GetNameOfEntity(ent_Glad) << " is defending..." << endl;
						Sleep(800);
						if((battleCount == 1) || (battleCount == 6) || (battleCount == 7))
							gladDead = glad->OnDefend(knig.Attack());
						else if ((battleCount == 2) || (battleCount == 3))
							gladDead = glad->OnDefend(guard.Attack());
						else if ((battleCount == 4) || (battleCount == 5))
							gladDead = glad->OnDefend(merc.Attack());
					}
					else if (choice == '3')
					{
						//use item
						bool found = false;
						char pick = '0';
						int n = 1;
						//display all usable items
						cout << setw(26) << left << "\nITEMS" << "QTY" << endl;
						cout << "------------------------------" << endl;
						for(int i = 0; i < glad->pack.getSize(); i++)
						{
							if((glad->pack.getInv(i) > 0) && (glad->pack.getType(i) == 'h'))
							{
								cout << n << " - " << setw(21) << left << glad->pack.getName(i) << setw(3) << right << glad->pack.getInv(i) << endl;
								n++;
								found = true;
							}
						}
						if(found == false)
						{
							//no items in inventory
							cout << "\nNo useable items in inventory\n" << endl;
						}
						else
						{
							cout << "\nEnter number to use item, or 0 to return to options: ";
							cin >> pick;

							if(isdigit(pick) && (pick != '0'))
							{
								//convert to int
								pick = atoi(&pick);
								//reset n
								n = 1;

								for(int i = 0; i < glad->pack.getSize(); i++)
								{
									if((glad->pack.getInv(i) > 0) && (glad->pack.getType(i) == 'h'))
									{
										if(pick == n)
										{
											//add health boost
											glad->healthBoost(glad->pack.getItemBoost(i));
											//decrement item from inventory
											glad->pack.decrementInv(i);
											
											cout << "\n" << setw(5) << left << " " << GetNameOfEntity(ent_Glad) << " is using item..." << endl;
											cout << "\n" << setw(12) << left << " " << "+" << glad->pack.getItemBoost(i) << "HP" << endl;

											//enemy still gets to attack
											if((battleCount == 1) || (battleCount == 6) || (battleCount == 7))
												gladDead = glad->ReceiveDamage(knig.Attack());
											else if ((battleCount == 2) || (battleCount == 3))
												gladDead = glad->ReceiveDamage(guard.Attack());
											else if ((battleCount == 4) || (battleCount == 5))
												gladDead = glad->ReceiveDamage(merc.Attack());
										}
										n++;
									}
								}
							}
							else if (pick != '0')
							{
								cout << "Not an option" << endl;
							}
						}

					}
					else if (choice == '4')
					{
						//run away  (still take damage)
						cout << "\n" << setw(5) << left << " " << GetNameOfEntity(ent_Glad) << " is running away..." << endl;
						Sleep(800);
						if((battleCount == 1) || (battleCount == 6) || (battleCount == 7))
							gladDead = glad->ReceiveDamage(knig.Attack());
						else if ((battleCount == 2) || (battleCount == 3))
							gladDead = glad->ReceiveDamage(guard.Attack());
						else if ((battleCount == 4) || (battleCount == 5))
							gladDead = glad->ReceiveDamage(merc.Attack());
						return;
					}
					//check if player has a defense bonus and decrement each round
					glad->defenseCheck();
				}
				if(gladDead == true)
					break;
				if(m < 6)
				{
					//since the same guard object is being used, 
					//we need to reset some values
					enemDead = false;
					guard.setData(350, 210, 195);
					merc.setData(400, 230, 195);
					knig.setData(450, 230, 205);
					if((battleCount) == 1)
						cout << "\n\n" << setw(5) << left << " " << "A guard has appeared..." << endl;
					else if((battleCount) == 2)
						cout << "\n\n" << setw(5) << left << " " << "Another guard has appeared..." << endl;
					else if((battleCount) == 3)
						cout << "\n\n" << setw(5) << left << " " << "A mercenary has appeared..." << endl;
					else if((battleCount) == 4)
						cout << "\n\n" << setw(5) << left << " " << "Another mercenary has appeared..." << endl;
					else if((battleCount == 5) || (battleCount == 6))
						cout << "\n\n" << setw(5) << left << " " << "Another knight has appeared..." << endl;

					battleCount++;
				}
			}
			if(enemDead == true)
			{
				cout << "\n" << GetNameOfEntity(ent_Glad) << ": I'm so exhausted..." << endl;
				cout << setw(8) << left << "\nVICTORY!\n" << endl;
				//EXP and money is the same for all levels in this match
				xp = 3000;
				mon = 800;

				glad->victory(xp, mon);

				//display short text-based cutscene
				displayCutscene();

				//reset enemDead
				enemDead = false;
				boss.setData(600, 250, 200);
				while((gladDead != true) && (enemDead != true))
				{
					cout << "\nHP: ";
					glad->printHP();
					cout << endl;
					cout << "1 - Attack" << endl;
					cout << "2 - Defend" << endl;
					cout << "3 - Use Item" << endl;
					//no option to run away
					cout << "Enter choice: ";
					cin >> choice;

					Sleep(800);
					if(choice == '1')
					{
						//attack
						cout << "\n" << setw(5) << left << " " << GetNameOfEntity(ent_Glad) << " is attacking..." << endl;
						Sleep(800);
						enemDead = boss.Damage(glad->AttackDamage());
						//make sure enemy is not dead first
						if(enemDead == false)
						{
							Sleep(800);
							gladDead = glad->ReceiveDamage(boss.Attack());
						}
					}
					else if (choice == '2')
					{
						//defend
						cout << "\n" << setw(5) << left << " " << GetNameOfEntity(ent_Glad) << " is defending..." << endl;
						Sleep(800);
						gladDead = glad->OnDefend(boss.Attack());
					}
					else if (choice == '3')
					{
						//use item
						bool found = false;
						char pick = '0';
						int n = 1;
						//display all usable items
						cout << setw(26) << left << "\nITEMS" << "QTY" << endl;
						cout << "------------------------------" << endl;
						for(int i = 0; i < glad->pack.getSize(); i++)
						{
							if((glad->pack.getInv(i) > 0) && (glad->pack.getType(i) == 'h'))
							{
								cout << n << " - " << setw(21) << left << glad->pack.getName(i) << setw(3) << right << glad->pack.getInv(i) << endl;
								n++;
								found = true;
							}
						}
						if(found == false)
						{
							//no items in inventory
							cout << "\nNo useable items in inventory\n" << endl;
						}
						else
						{
							cout << "\nEnter number to use item, or 0 to return to options: ";
							cin >> pick;

							if(isdigit(pick) && (pick != '0'))
							{
								//convert to int
								pick = atoi(&pick);
								//reset n
								n = 1;

								for(int i = 0; i < glad->pack.getSize(); i++)
								{
									if((glad->pack.getInv(i) > 0) && (glad->pack.getType(i) == 'h'))
									{
										if(pick == n)
										{
											//add health boost
											glad->healthBoost(glad->pack.getItemBoost(i));
											//decrement item from inventory
											glad->pack.decrementInv(i);
											
											cout << "\n" << setw(5) << left << " " << GetNameOfEntity(ent_Glad) << " is using item..." << endl;
											cout << "\n" << setw(12) << left << " " << "+" << glad->pack.getItemBoost(i) << "HP" << endl;

											//enemy still gets to attack
											gladDead = glad->ReceiveDamage(boss.Attack());
										}
										n++;
									}
								}
							}
							else if (pick != '0')
							{
								cout << "Not an option" << endl;
							}
						}

					}
					//check if player has a defense bonus and decrement each round
					glad->defenseCheck();
				}
				if(enemDead == true)
				{
					cout << "\n" << GetNameOfEntity(ent_Glad) << ": Alright!" << endl;
					cout << setw(8) << left << "\nVICTORY!\n" << endl;
					//EXP and money rewareded is the same for all levels
					xp = 6000;
					mon = 2000;

					glad->victory(xp, mon);
					
					//display short ending scene
					endingScene();
				}
				if(gladDead == true)
				{
					cout << "\n\n\n" << setw(8) << left << " " << "GAME OVER\n\n" << endl;
					glad->ChangeLocation(Dead);
					return;
				}
			}
			if(gladDead == true)
			{
				cout << "\n\n\n" << setw(8) << left << " " << "GAME OVER\n\n" << endl;
				glad->ChangeLocation(Dead);
				return;
			}
			cout << "\n" << endl;
			break;
		case '6':
			//quit
			break;
		default:
			//invalid
			cout << "\n" << GetNameOfEntity(ent_Area) << ": Are you speaking in english?\n" << endl;
			break;
		}
	}
}

void theArena::Exit(Gladiator* glad)
{
	//exit theArena
}